/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.getsoftware.davicalcados.gui.cadastro;

import br.com.getsoftware.davicalcados.bo.CaixaBO;
import br.com.getsoftware.davicalcados.entity.Caixa;
import br.com.getsoftware.davicalcados.exception.FormatoSQLException;
import br.com.getsoftware.davicalcados.gui.acesso.TelaMenuGUI;
import br.com.getsoftware.davicalcados.util.MeuRenderer;
import static br.com.getsoftware.davicalcados.util.MeuRenderer.DEFAULT_RENDERER;
import br.com.getsoftware.davicalcados.util.MyDate;
import br.com.getsoftware.davicalcados.util.TransformMoeda;
import java.awt.Color;
import java.awt.Component;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;

/**
 *
 * @author Junior Oliveira
 */
public class CaixaGUI extends javax.swing.JFrame {

    /**
     * Creates new form DetalhesGUI
     */
    public CaixaGUI() throws SQLException {
        initComponents();
         dadosTabela();
    }

    private ArrayList<Caixa> listCaixa;
    private int linhaSelecionada = 0;
    private TelaMenuGUI telaMenu;
    private TelaMenuGUI menu;

    public CaixaGUI(TelaMenuGUI menu) throws SQLException {
        this();
        this.menu = menu;
        dadosTabela();
        atualizaLinhaSelecionada();
        jLdata.setText(MyDate.dataFormatada());
        TableCellRenderer tcr = new MeuRenderer();
        TableColumn column = jTable1.getColumnModel().getColumn(1);
        column.setCellRenderer(tcr);
    }

    public void atualizaLinhaSelecionada() {
        linhaSelecionada = 0;
        jTable1.getSelectionModel().setSelectionInterval(linhaSelecionada, linhaSelecionada);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLasda = new javax.swing.JLabel();
        jLabel = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLgeral = new javax.swing.JLabel();
        jLsaida = new javax.swing.JLabel();
        jLentrada = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jBcadEntrada = new javax.swing.JButton();
        jBcadSaida = new javax.swing.JButton();
        jBvenda = new javax.swing.JButton();
        jBreceberPagamento = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLdata = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(204, 0, 0));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Detalhes de Movimentação");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(367, 367, 367)
                .addComponent(jLabel1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jTable1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Identificador", "Movimentação", "Descrição", "Horário", "Funcionário", "Valor"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.getTableHeader().setResizingAllowed(false);
        jTable1.getTableHeader().setReorderingAllowed(false);
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);
        if (jTable1.getColumnModel().getColumnCount() > 0) {
            jTable1.getColumnModel().getColumn(0).setResizable(false);
            jTable1.getColumnModel().getColumn(0).setPreferredWidth(8);
            jTable1.getColumnModel().getColumn(1).setResizable(false);
            jTable1.getColumnModel().getColumn(1).setPreferredWidth(15);
            jTable1.getColumnModel().getColumn(2).setResizable(false);
            jTable1.getColumnModel().getColumn(2).setPreferredWidth(350);
            jTable1.getColumnModel().getColumn(3).setResizable(false);
            jTable1.getColumnModel().getColumn(3).setPreferredWidth(15);
            jTable1.getColumnModel().getColumn(4).setResizable(false);
            jTable1.getColumnModel().getColumn(4).setPreferredWidth(25);
            jTable1.getColumnModel().getColumn(5).setResizable(false);
            jTable1.getColumnModel().getColumn(5).setPreferredWidth(15);
        }

        jLasda.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLasda.setForeground(new java.awt.Color(0, 153, 0));
        jLasda.setText("Total Entrada");

        jLabel.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel.setForeground(new java.awt.Color(204, 0, 0));
        jLabel.setText("Total Saída");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 20)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(51, 0, 204));
        jLabel4.setText("Total em Caixa");

        jLgeral.setFont(new java.awt.Font("Tahoma", 1, 20)); // NOI18N
        jLgeral.setForeground(new java.awt.Color(51, 0, 204));
        jLgeral.setText("00,00");

        jLsaida.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLsaida.setForeground(new java.awt.Color(204, 0, 0));
        jLsaida.setText("00,00");

        jLentrada.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLentrada.setForeground(new java.awt.Color(0, 153, 0));
        jLentrada.setText("00,00");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1148, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLasda)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLentrada)
                        .addGap(171, 171, 171)
                        .addComponent(jLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLsaida)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel4)
                        .addGap(18, 18, 18)
                        .addComponent(jLgeral)
                        .addGap(130, 130, 130))))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 392, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLasda)
                    .addComponent(jLabel)
                    .addComponent(jLabel4)
                    .addComponent(jLgeral)
                    .addComponent(jLsaida)
                    .addComponent(jLentrada))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jBcadEntrada.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/getsoftware/davicalcados/icons/entrada.png"))); // NOI18N
        jBcadEntrada.setText("CadEntrada");
        jBcadEntrada.setToolTipText("Cadastrar uma entrada");
        jBcadEntrada.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jBcadEntrada.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBcadEntradaActionPerformed(evt);
            }
        });

        jBcadSaida.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/getsoftware/davicalcados/icons/saida.png"))); // NOI18N
        jBcadSaida.setText("CadSaída");
        jBcadSaida.setToolTipText("Cadastrar uma saida");
        jBcadSaida.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jBcadSaida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBcadSaidaActionPerformed(evt);
            }
        });

        jBvenda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/getsoftware/davicalcados/icons/Cash-register-icon.png"))); // NOI18N
        jBvenda.setText("Efetuar venda");
        jBvenda.setToolTipText("Efetuar uma venda");
        jBvenda.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jBvenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBvendaActionPerformed(evt);
            }
        });

        jBreceberPagamento.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/getsoftware/davicalcados/icons/Apps-kmymoney-icon.png"))); // NOI18N
        jBreceberPagamento.setText("Rec Pgto");
        jBreceberPagamento.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jBreceberPagamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBreceberPagamentoActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel2.setText("Data:");

        jLdata.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLdata.setText("jLabel2");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jBcadEntrada)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBcadSaida)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBreceberPagamento)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBvenda)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLdata)
                .addGap(138, 138, 138))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jBcadEntrada, jBcadSaida, jBreceberPagamento, jBvenda});

        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(jLdata))
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jBcadEntrada)
                        .addComponent(jBcadSaida)
                        .addComponent(jBreceberPagamento)
                        .addComponent(jBvenda)))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jBcadEntrada, jBcadSaida, jBreceberPagamento, jBvenda});

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        setSize(new java.awt.Dimension(1208, 623));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        menu.setEnabled(true);
        this.dispose();
    }//GEN-LAST:event_formWindowClosing

    private void jBcadEntradaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBcadEntradaActionPerformed
        this.setEnabled(false);
        try {
            new CadEntradasGUI(this).setVisible(true);
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Não foi possível abrir a tela de cadastro de entradas!", "Erro", 0);
        }
    }//GEN-LAST:event_jBcadEntradaActionPerformed

    private void jBcadSaidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBcadSaidaActionPerformed
        this.setEnabled(false);
        try {
            new CadSaidaGUI(this).setVisible(true);
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Não foi possível abrir a tela de cadastro de saídas!", "Erro", 0);
        } catch (FormatoSQLException ex) {
           JOptionPane.showMessageDialog(null, ex);
        }
    }//GEN-LAST:event_jBcadSaidaActionPerformed

    private void jBreceberPagamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBreceberPagamentoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jBreceberPagamentoActionPerformed

    private void jBvendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBvendaActionPerformed
        this.setEnabled(false);
        new CadVendaGUI(this).setVisible(true);
    }//GEN-LAST:event_jBvendaActionPerformed

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
//       linhaSelecionada = jTable1.getSelectedRow();
//        if (jTable1.getValueAt(linhaSelecionada, 1).toString().equals("Entrada")) {
//            jTable1.setSelectionBackground(Color.getHSBColor(10, 50, 100));
//            jTable1.setSelectionForeground(Color.black);
//        } else if (jTable1.getValueAt(linhaSelecionada, 1).toString().equals("Saída")) {
//            jTable1.setSelectionBackground(Color.getHSBColor(10, 100, 255));
//            jTable1.setSelectionForeground(Color.black);
//        } else {
//            jTable1.setSelectionBackground(Color.white);
//            jTable1.setSelectionForeground(Color.black);
//        }
//        System.out.println(jTable1.getValueAt(linhaSelecionada, 1).toString());
    }//GEN-LAST:event_jTable1MouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CaixaGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CaixaGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CaixaGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CaixaGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new CaixaGUI().setVisible(true);
                } catch (SQLException ex) {
                    JOptionPane.showMessageDialog(null, "Não foi possível abrir a tela de caixa!", "Erro", 0);
                }
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBcadEntrada;
    private javax.swing.JButton jBcadSaida;
    private javax.swing.JButton jBreceberPagamento;
    private javax.swing.JButton jBvenda;
    private javax.swing.JLabel jLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLasda;
    private javax.swing.JLabel jLdata;
    private javax.swing.JLabel jLentrada;
    private javax.swing.JLabel jLgeral;
    private javax.swing.JLabel jLsaida;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables

    public void filter() {
//        if (jRnome.isSelected()) {
//            dadosPesquisaPorNome();
//        } else if (jRid.isSelected()) {
//            dadosPesquisaPorID();
//        } else if (jRcpf.isSelected()) {
//            dadosPesquisaPorCPF();
//        }
        atualizaLinhaSelecionada();
    }

    public void dadosTabela() throws SQLException {

        listCaixa = CaixaBO.listAll();

        DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
        modelo.setNumRows(0);
        
        for (int i = 0; i < listCaixa.size(); i++) {
            modelo.addRow(new Object[]{
                listCaixa.get(i).getIdCaixa(),
                listCaixa.get(i).getTipoMovimentacao(),
                listCaixa.get(i).getDescricao(),
                listCaixa.get(i).getHora(),
                listCaixa.get(i).getIdUsuario(),
                TransformMoeda.trasnformMoeda("" + listCaixa.get(i).getValor())});
        }
        jLentrada.setText(TransformMoeda.trasnformMoeda("" + entradas()));
        jLsaida.setText(TransformMoeda.trasnformMoeda("" + saidas()));
        jLgeral.setText(TransformMoeda.trasnformMoeda("" + totalGeral()));
    }

    public BigDecimal entradas() {
        Double valor = new Double(0);
        for (int i = 0; i < listCaixa.size(); i++) {
            if (listCaixa.get(i).getTipoMovimentacao().equals("Entrada")) {
                valor += listCaixa.get(i).getValor();
              }
        }
        BigDecimal total = new BigDecimal(valor).setScale(2, RoundingMode.HALF_EVEN);
        return total;
    }

    public BigDecimal saidas() {
        Double valor = new Double(0);
        for (int i = 0; i < listCaixa.size(); i++) {
            if (listCaixa.get(i).getTipoMovimentacao().equals("Saída")) {
                valor += listCaixa.get(i).getValor();
            }
        }
        BigDecimal total = new BigDecimal(valor).setScale(2, RoundingMode.HALF_EVEN);
        return total;
    }

    public BigDecimal totalGeral() {
        Double entrada = entradas().doubleValue();
        Double saida = saidas().doubleValue();
        BigDecimal total = new BigDecimal(entrada - saida).setScale(2, RoundingMode.HALF_EVEN);
        return total;
    }
     
}
